<template>
  <div>
    <home-header ></home-header>
    <home-swiper :list="swiperList"></home-swiper>
    <home-icons :list="iconList"></home-icons>
    <home-recommde :list="recommendList"></home-recommde>
    <home-weekend :list="weekendList"></home-weekend>
  </div>
</template>

<script>
import axios from 'axios'
import HomeHeader from './components/header'
import HomeSwiper from './components/swiper'
import HomeIcons from './components/icons'
import HomeRecommde from './components/recommed'
import HomeWeekend from './components/weekend'
import {mapState} from 'vuex'
export default {
  data () {
    return {
      lastCity: '',
      dataList: '',
      swiperList: [],
      iconList: [],
      recommendList: [],
      weekendList: []
    }
  },
  components: {HomeHeader, HomeSwiper, HomeIcons, HomeRecommde, HomeWeekend},
  mounted () {
    this.lastCity = this.city
    this.getHomeInfo()
  },
  activated () {
    if (this.lastCity !== this.city) {
      this.lastCity = this.city
      this.getHomeInfo()
    }
  },
  computed: {
    ...mapState(['city'])
  },
  methods: {
    getHomeInfo () {
      axios.get('/api/mock/5b335032b3c5711bec1ff3b9/travel/data?city=' + this.city).then(res => {
        // debugger
        if (res.data.ret) {
          this.dataList = res.data.data
          this.swiperList = res.data.data.swiperList
          console.log(res.data)
          this.iconList = res.data.data.iconList
          this.recommendList = res.data.data.recommendList
          this.weekendList = res.data.data.weekendList
        }
      })
    }
  }
}
</script>

<style lang="stylus" scoped>
</style>
